﻿<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:DistributedSearchs_Common="clr-namespace:DistributedSearchs.Common"
        xmlns:local="clr-namespace:DistributedSearchs" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
        xmlns:ReactiveUI_Blend="clr-namespace:ReactiveUI.Blend;assembly=ReactiveUI.Blend" mc:Ignorable="d"
        x:Class="DistributedSearchs.MainWindow" Title="MainWindow" Height="480" Width="640"
        DataContext="{Binding ViewModel, RelativeSource={RelativeSource Mode=Self}}">
  <Window.Resources>
    <Style x:Key="ListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
      <Setter Property="HorizontalContentAlignment" Value="Stretch" />
      <Setter Property="VerticalContentAlignment" Value="Stretch" />
    </Style>
  </Window.Resources>
  <extToolkit:BusyIndicator BusyContent="Searching for nodes..." IsBusy="{Binding IsBusy}">
    <DockPanel>
      <ToolBar VerticalAlignment="Top" DockPanel.Dock="Top" IsOverflowOpen="True">
        <Button Command="{Binding ScanNowCommand}">
          <StackPanel Orientation="Horizontal">
            <Ellipse Height="15" HorizontalAlignment="Left" Width="15" Margin="0,0,3,0" Fill="#FF79FF30">
              <Ellipse.OpacityMask>
                <RadialGradientBrush>
                  <GradientStop Color="Black" Offset="0" />
                  <GradientStop Offset="1" Color="#44FFFFFF" />
                </RadialGradientBrush>
              </Ellipse.OpacityMask>
            </Ellipse>
            <TextBlock Text="Scan Files Now" />
          </StackPanel>
        </Button>
        <Button Content="Folder Management" Command="{Binding FolderManagementCommand}" />
        <Separator />
        <Button Content="Add client" />
        <Button Content="Discover Nodes" Command="{Binding DiscoverNodesCommand}" />
        <CheckBox Content="Activate Host" IsChecked="{Binding IsHostStarted, Mode=TwoWay}"/>
      </ToolBar>
      <Grid Margin="8">
        <Grid.RowDefinitions>
          <RowDefinition Height="22.5" />
          <RowDefinition />
        </Grid.RowDefinitions>
        <ListBox x:Name="listBox1" ItemsSource="{Binding Files}" Margin="0,4.5,0,0" Grid.Row="1"
                 HorizontalContentAlignment="Stretch" ItemContainerStyle="{DynamicResource ListBoxItemStyle}">
          <ListBox.ItemTemplate>
            <DataTemplate>
              <Border Padding="5" BorderThickness="1" BorderBrush="Black" Background="#FFF3E3D3" CornerRadius="3"
                      Margin="2,3">
                <DockPanel>
                  <Button Content="Download" DockPanel.Dock="Right" Margin="5,0" VerticalAlignment="Center"
                          Command="{Binding DownloadCommand}" />
                  <Button Content="Request Info" DockPanel.Dock="Top" HorizontalAlignment="Left" Margin="5,0,0,0"
                          Command="{Binding MoreInfoCommand}" />
                  <local:InlinedTextBlock InlineSource="{Binding Preview}" />
                </DockPanel>
              </Border>
            </DataTemplate>
          </ListBox.ItemTemplate>
        </ListBox>
        <TextBox Text="{Binding CurrentQuery, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="28,0,24,0" />
        <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Center">
          <Run Text="Find" />
        </TextBlock>
        <Button Content="Go" HorizontalAlignment="Right" Command="{Binding SearchCommand}" />
      </Grid>
    </DockPanel>
  </extToolkit:BusyIndicator>
</Window>